/**
 * 
 */
package com.scpii.universal.hibernate.dao.impl;

import org.springframework.stereotype.Repository;

import com.scpii.universal.constant.GenericConstants;
import com.scpii.universal.hibernate.dao.AppDao;
import com.scpii.universal.hibernate.entity.AppTab;

/**
 * genericWeb
 * @author weny
 * 2012-7-6上午10:16:50
 */
@Repository
public class AppDaoImpl extends BaseDaoImpl<AppTab, Integer>  implements AppDao {

	@Override
	public AppTab getAppInfoById(int appId, String[] properties) {
		String hql = generateHqlByProperties(properties)
				+ "where entity.intAppId=?";
		return (AppTab) getHibernateTemplate().getSessionFactory()
				.getCurrentSession().createQuery(hql).setParameter(0, appId)
				.uniqueResult();
	}

	@Override
	public Long getTotalCount(int appId) {
		StringBuffer hql = new StringBuffer();
		hql.append("select count(*) from AppPageTab a");
		hql.append(" where a.intDeleteSign=?");
		hql.append(" and a.intAppId=?");
		return (Long) getHibernateTemplate().getSessionFactory()
				.getCurrentSession().createQuery(hql.toString())
				.setParameter(0, GenericConstants.DELETE_SIGN_EXIST)
				.setParameter(1, appId).uniqueResult();
	}
	
}
